package com.colin.app.fragment.permission;

import android.Manifest;

import com.colin.app.app.AppActivity;
import com.colin.app.app.BasePresenterImpl;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Colin on 2017/1/15.
 */

public class PermissionPresenterImpl extends BasePresenterImpl implements PermissionContract.PermissionPresenter {

    private PermissionContract.PermissionView mPermissionView;
    private PermissionContract.PermissionModel mPermissionModel;

    public PermissionPresenterImpl(AppActivity mAppActivity, PermissionContract.PermissionView mPermissionView) {
        super(mAppActivity, mPermissionView);
        this.mPermissionView = mPermissionView;
        this.mPermissionModel = new PermissionModelImpl();


    }

    @Override
    public void checkPermissionCamera() {
        if (mPermissionView.checkPermission(Manifest.permission.CAMERA)){
            mPermissionView.toastShow("获取到权限");
        }
    }

    @Override
    public void checkPermissionContacts() {
        if (mPermissionView.checkPermission(Manifest.permission.READ_CONTACTS)){
            mPermissionView.toastShow("获取到权限");
        }
    }

    @Override
    public void checkPermissionStorage() {
        if (mPermissionView.checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)){
            mPermissionView.toastShow("获取到权限");
        }
    }

    @Override
    public void checkPermissionMore() {
        List<String> permissionList = new ArrayList<>();
        permissionList.add(Manifest.permission.CAMERA);
        permissionList.add(Manifest.permission.READ_CONTACTS);
        permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
        mPermissionView.checkPermission(permissionList);
        if (mPermissionView.checkPermission(permissionList)){
            mPermissionView.toastShow("获取到权限");
        }
    }
}
